Imports System.Collections

Partial Class pages_speakers_usercontrols_UCSpeaker : Inherits UserControl

#Region "Members"
    Private m_speaker As CSpeaker
    Private m_sortedList As IList
#End Region

#Region "Interface"
    Public Sub Display(ByVal [speaker] As CSpeaker, sortedList as IList)
        If Parent.Controls.Count Mod 2 = 0 Then row.Attributes.Add("class", "alt_row")

        m_speaker = [speaker]
        m_sortedList = sortedList

        With m_speaker
            litNumber.Text = CStr(sortedList.IndexOf(m_speaker) + 1)
            lnkSpeakerName.Text = CStr(IIf(.SpeakerName.Length = 0, "...", .SpeakerName))
            lnkSpeakerName.NavigateUrl = CSitemap.SpeakerEdit(.SpeakerId)

            lnkProducts.Text = CUtilities.CountSummary(.Products, "sermon", "none")
            lnkProducts.NavigateUrl = CSitemap.ProductsForSpeaker(.SpeakerId)

            lnkWebsite.Text = CUtilities.Truncate(.SpeakerWebsite)
            lnkWebsite.NavigateUrl = "http://" & .SpeakerWebsite

            lnkSpeakerImage.Text = CUtilities.Truncate(.SpeakerImage)
            lnkSpeakerImage.NavigateUrl = CSitemap.SpeakerUploads & .SpeakerImage
            litSpeakerAbout.Text = HttpUtility.HtmlEncode(CUtilities.Truncate(.SpeakerAbout))
            litSpeakerContactPhone.Text = CUtilities.Truncate(.SpeakerContactPhone)
            litSpeakerContactEmail.Text = .SpeakerContactEmail
        End With
    End Sub
#End Region

#Region "Event Handlers"
    Private Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnDelete.Click
        m_speaker.Delete()
        Refresh()
    End Sub
#End Region

#Region "Private"
    Private Sub Refresh()
        'CCache.ClearCache()

        'If False Then 'Request.RawUrl.ToLower.Contains("myparent.aspx") Then
        '    'Special case: Parent entity owns the list
        '    Response.Redirect(CSitemap.MyParentEdit(m_speaker.SpeakerParentId, MyParent.ETab.speakers, m_pageIndex)
        'Else
        '    'Normal case: Search page owns the list
            Response.Redirect(Request.RawUrl) 'includes paging info
        'End If 
    End Sub
#End Region

End Class
